<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
    <title>代理商管理系统</title>
    <link rel="stylesheet" type="text/css" href="${ctx}/statics/easyui/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="${ctx}/statics/easyui/themes/icon.css" />
    <link rel="stylesheet" type="text/css" href="${ctx}/statics/easyui/themes/color.css" />
    <link rel="stylesheet" type="text/css" href="${ctx}/statics/easyui/themes/demo.css" />
    <script src="${ctx}/statics/easyui/jquery.min.js" type="text/javascript"></script>
    <script src="${ctx}/statics/easyui/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="${ctx}/statics/easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
</head>
<body class="easyui-layout" >
    <div data-options="region:'center',border:false" style="width:100%;text-align:center" >
        <h5>APP URL管理-请填写制作APP的系统的URL地址</h5>
        <div style="margin:20px 10px;border-top:1px solid darkgray">
            <form id="appForm">
                <table id="ct" style="margin:20px auto;" cellpadding="10px">
                    <tr>
                        <td>配置名称:</td>
                        <td><input class="easyui-textbox" type="text" name="configTypeName" style="width:120px"
                                   data-options="required:true,missingMessage:'配置名称不能为空'" />
                        </td>
                    </tr>
                    <tr>
                        <td>配置数值:</td>
                        <td><input class="easyui-textbox" type="text" name="configValue" style="width:120px"
                                   data-options="required:true,missingMessage:'配置数值不能为空'" />
                        </td>
                    </tr>
                </table>
            </form>
        </div>
        <div>
            <a id="confirm" class="easyui-linkbutton" data-options="iconCls:'icon-save',size:'small'" href="javascript:void(0)"
               style="width:80px">保存</a>
        </div>
    </div>

    <script>
        $(
            function ()
            {
                var configId = 31;
                $.ajax(
                    {
                        //页面加载发送请求读取数据
                        type:"POST",
                        url:"${ctx}/do/selectConfig",
                        data:{"configId":configId,"configType":4},
                        dataType:"json",
                        success:function ( json )
                        {
                            $("#appForm").form( 'load' ,
                                {
                                    configTypeName:json.configTypeName,
                                    configValue:json.configValue
                                });
                            //成功加载数据后为保存按钮注册事件
                            $("#confirm").off('click').on('click',
                                function ()
                                {
                                    //设置表单请求
                                    $("#appForm").form(
                                        {
                                            url:"${ctx}/do/updateConfig",
                                            //提交前设置表单携带参数
                                            onSubmit: function(param){
                                                param.id = configId;
                                                param.isStart = true;
                                                param.configType = 4;
                                            },
                                            //提交成功后处理返回值
                                            success:function(data)
                                            {
                                                //注意需要将返回值转换为json
                                                var json = JSON.parse(data);
                                                infoWindows( "修改" , json );
                                            }
                                        });
                                    //提交表单
                                    $("#appForm").submit();
                                });
                        }
                    });
            }
        );

        //消息提示窗口
        function infoWindows( str , json )
        {
            var title = str + "操作";
            var info = (json.message == 1?(str + "成功"):( str + "失败"));
            var icon = (json.message == 1?"info":"error");
            $.messager.alert(title,info,icon);
        }

    </script>
</body>
</html>
